/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package retrieval;

import java.util.ArrayList;

/**
 *
 * @author Danang
 */
public class SearchConsecutiveModul {
    ArrayList<Integer> list;
    
    int head;
    
    public SearchConsecutiveModul(ArrayList<Integer> list) {
        this.list = list;
        head = 0;
    }
    
    public void advHead() {
        head++;
    }
    
    public int getHead() {
        if (head>=list.size()) {
            return -1;
        }
        return list.get(head);
    }
    
    public int getNextHead() {
        if (head+1>=list.size()) {
            return -1;
        }
        return list.get(head+1);
    }
    
    public int getPrevHead() {
        if (head==0) {
            return -1;
        }
        return list.get(head-1);
    }
    
    public void advNext(int nextHead) {
        while (getNextHead()!=-1 && getNextHead()<=nextHead) {
            advHead();
        }
    }
    
}
